﻿package view.components.contacts 
{
	import flash.display.MovieClip;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	/**
	 * ...
	 * @author Lobanov
	 */
	public class AboutMaterial extends MovieClip
	{
		public var aboutInfo_txt:TextField;
		
		public function AboutMaterial($text:String = "simple text")
		{
			var style:StyleSheet = new StyleSheet();
            var body:Object = new Object();
            body.fontStyle = "italic";
            style.setStyle("body", body);
			
			aboutInfo_txt.styleSheet = style;
			
			aboutInfo_txt.autoSize = TextFieldAutoSize.LEFT;
			aboutInfo_txt.htmlText = "<body>";
			
			var sentenceArr:Array = [];
			sentenceArr = $text.split("<br>");
			
			for (var i:int = 0; i < sentenceArr.length; i++ ) {
				aboutInfo_txt.htmlText += getShift(i, sentenceArr.length)+sentenceArr[i] + "<br>";
				(i == sentenceArr.length - 1) ? aboutInfo_txt.htmlText += "</body>" : null;
			}
		}
		
		private function getShift($position:int, $num:int):String {
			var s:String = "";
			var inc:int = $num - $position;
			
			while (--inc) {
				s += " ";
			}
			
			return s;
		}
	}
}